﻿using DocumentMakingTools.Views;
using Newtonsoft.Json;
using System.Diagnostics;
using System.Text.Json.Serialization;

namespace DocumentMakingTools;

public partial class AppShell : Shell
{
	public AppShell()
	{
		InitializeComponent();

        Routing.RegisterRoute("WebViewPage", typeof(WebViewPage));
	}
	protected override async void OnDisappearing()
	{
        base.OnDisappearing();

        // 写文件
        string targetFile = System.IO.Path.Combine(FileSystem.Current.AppDataDirectory, "AppSettings");
        // using FileStream outputStream = System.IO.File.OpenWrite(targetFile);
        using StreamWriter streamWriter = new StreamWriter(targetFile, false);

        var content = JsonConvert.SerializeObject(App.AppSetting);
        await streamWriter.WriteAsync(content);
    }
}
